﻿using FluentNHibernate.Mapping;

namespace TaskKernel.Domain.Nhibernate.Mappings
{
    public class TemplateMap : ClassMap<Template>
    {
        public TemplateMap()
        {
            Table("task_Templates");
            Id(x => x.UID, "GID").GeneratedBy.GuidNative();
            Map(x => x.Name, "Name");
            Map(x => x.ContentNameResource, "ResourceName");
            HasManyToMany(x => x.Departments)
                .ParentKeyColumn("TemplateGID")
                .ChildKeyColumn("DepartmentGID")
                .Table("task_TemplateDepartment")
                .Inverse()
                .Cascade.All().LazyLoad()
                .AsBag().Access.ReadOnlyPropertyThroughCamelCaseField();
        }
    }
}